Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development


Retrieving related information for an object

This section outlines how you retrieve various kinds of information in the cache that is related to an object, and which completes the definition of the object.

Retrieving the instance ID for an object

Before finding any related information, you must have the instance ID (the tRecordIdentifier field value) of the record whose associated information you require. There are several ways of doing this.

If the object is running, you can retrieve the instance ID as an object property using the ADM property include file syntax. In this example, the object handle is in the variable hObject and the Record Identifier is retrieved into the variable dInstanceID:

{get InstanceId dInstanceId hObject}  

Or you can use the equivalent function call, as shown:

dInstanceID = DYNAMIC-FUNCTION(‘getInstanceID’ IN hObject). 

Alternatively, the object that you request using cacheObjectOnClient() is available immediately after the call to that function. You can then use a statement such as the following to return the buffer handle to the cache_Object temp-table, which will also be positioned to the requested record:

ASSIGN hObjectBuffer =  
  DYNAMIC-FUNCTION(“getCacheObjectBuffer”:U IN gshRepositoryManager, INPUT 
?). 

After finding the cache_Object buffer, do a FIND based on your own criteria to position to the relevant record. Once you have found an available hObjectBuffer record, you can populate the dInstanceId variable using a statement such as this:

ASSIGN dInstanceId =  
    hObjectBuffer:BUFFER-FIELD(“tRecordIdentifier”:U):BUFFER-VALUE. 

Getting the instance ID is the first step to getting all the other related information out of the cache.

Retrieving other object information

To get Page, Page instance, link, and UI event information for a particular object, first retrieve the buffer handle for the relevant cache buffer, using one of the functions getCachePageBuffer, getCachePageInstanceBuffer, getCacheLinkBuffer, or getCacheUIEventBuffer. In this code example, hBuffer is the buffer handle retrieved using one of those function calls. Create a dynamic query on that table, with a WHERE clause such as this:

hQuery:QUERY-PREPARE(" FOR EACH ":U + hBuffer " WHERE ":U 
+ hBuffer:NAME + ".tRecordIdentifier = " + QUOTER(dRecordIdentifier)  ). 

Retrieving attribute values for an object

To retrieve attribute values, you first must obtain the instance ID (the tRecordIdentifier field value) from the cache_Object record. Remember that the correct cache_Object record is AVAILABLE after a call to cacheObjectOnClient(). Otherwise, if you have the object’s instance ID, you can make a call to getCacheObjectBuffer(), passing in the instance ID. This ensures that the correct record is available to you. The tClassBufferHandle field contains the buffer handle of the record that contains the attributes for the object.

Using a statement such as the following, you can retrieve the attributes for the specific object. Note the use of the recently introduced dynamic FIND-FIRST method on a buffer handle, which allows you to position the buffer to a record using a dynamic WHERE clause, as shown:

hAttributeBuffer:FIND-FIRST(" WHERE ":U 
+ hAttributeBuffer:NAME + ".tRecordIdentifier = " + QUOTER(dRecordIdentifier)  
). 

You can now retrieve the values for the relevant field, as shown in the code sample earlier in this section.

Retrieving an object’s contained instances

There are two primary ways of getting all the contained instances for a container object. You can query all cache_Obect records where either:

The first alternative is simpler and requires less programming work since all that is needed is the instance ID, which is readily available. The other information required to use the second alternative requires various calls and possibly further calculation.

How attributes are stored

Each class has its own attribute temp-table, with a field for each attribute in the class. This includes all attributes inherited by the class from its parent classes. The initial value of each attribute field is the initial or default value of the attribute for that class. The temp-table is created dynamically by buildClassCache() and is called cache_<ClassName>. These tables and their buffer handles are then cached in the ttClass temp-table.

There are also a couple of fields which the cache_<ClassName> table uses internally:


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095